﻿using System;
using viBlog.Controllers;
using visinia.SmartEngine;
using visinia.SmartEngine.Modules;

public partial class Modules_viBlog_RecentComments_RecentComments : WebModule
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int count = 0;
        if (Int32.TryParse((string)Settings["Count"], out count))
        {                  
            RecentCommentsList.DataSource = CommentController.GetRecentComments(count);
            RecentCommentsList.DataBind();
            WebPageController.AddRssFeedLink(Page, BlogController.BlogName + " - Comments(RSS)", WebRoots.GetWebRoot + BlogController.BlogUrlSeparator + "/rss/Comments.aspx");
        }
    }

    public string TrimContents(string FullContents)
    {
        if (FullContents.Length > 80)
            return WebHelpers.StripHtml(FullContents.Remove(80)) + "...";
        else
            return WebHelpers.StripHtml(FullContents);
    }
}
